package com.itheima.arraylist;

import com.itheima.domain.Student;

import java.util.ArrayList;
import java.util.Scanner;

public class TestArrayList {
    public static void main(String[] args) {
        ArrayList<Student> list = new ArrayList<>();
        Student s1 = getStudent(1);
        Student s2 = getStudent(2);
        Student s3 = getStudent(3);



        list.add(s1);
        list.add(s2);
        list.add(s3);

        for (int i = 0;i < list.size();i++){
            System.out.println(list.get(i).getName()+"..."+list.get(i).getAge());



        }


    }

    public static Student getStudent(int count){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入第" + count+"学生姓名");
        String name = sc.next();
        System.out.println("请输入第" + count+"学生年龄");
        int age = sc.nextInt();
        Student stu = new Student(name,age);
        return stu;
    }

}
